package com.code.AZPlan.client.hystrix;

import com.code.AZPlan.client.AZPlanStaticIncomeClient;
import com.code.AZPlan.model.bo.*;
import com.code.AZPlan.model.po.*;
import com.code.commons.model.Model;
import com.code.commons.model.qo.PageQO;
import com.code.commons.model.vo.PageVO;
import com.google.common.collect.Maps;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.math.BigDecimal;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * 用户的熔断回调类
 *
 * @author tangyifei
 */
@Component
@Slf4j
public class AZPlanStaticIncomeClientHystrix implements AZPlanStaticIncomeClient {

    @Override
    public void reloadAccountTree() {
        log.info("刷新内存树发生请求超时，走熔断！");
    }

    @Override
    public MoneyTransferRecord moneyTransfer(@RequestBody MoneyTransferRecord moneyTransferRecord) {
        log.info("资金划转发生请求超时，走熔断！");
        return MoneyTransferRecord.builder().build();
    }

    @Override
    public ExchangeFlow insertExchangeFlow(@RequestBody ExchangeFlow exchangeFlow) {
        log.info("兑换请求超时，走熔断！");
        return ExchangeFlow.builder().build();
    }

    @Override
    public EntryMoneyBO entryMoney(@RequestBody EntryMoneyBO entryMoneyBO) throws Exception {
        log.info("入金请求超时，走熔断！");
        return EntryMoneyBO.builder().build();
    }

    @Override
    public AZPlanBalance getAZPlanBalanceByUserId(@PathVariable("userId") String userId) {
        log.info("根据用户主键获取用户的矿池大小请求超时，走熔断！");
        return AZPlanBalance.builder().build();
    }

    @Override
    public MoneyTransferRecord getMoneyTransferByUserIdAndCoinType(@PathVariable("userId") String userId, @RequestParam(value = "coinType", required = false) String coinType, @RequestParam(value = "coinAddress", required = false) String coinAddress, @RequestParam(value = "transferType", required = false) Integer transferType) {
        log.info("通过用户主键和币种类型获取资金划转信息请求超时，走熔断！");
        return MoneyTransferRecord.builder().build();
    }

    @Override
    public Map<String, Object> getOrePool(@RequestParam("userId") String userId, @RequestParam("coinType") String coinType) {
        log.info("通过用户主键和币种类型获取剩余矿池的大小请求超时，走熔断！");
        return Maps.newHashMap();
    }

    @Override
    public BigDecimal getTotalIncomeAmount(@RequestParam("userId") String userId) {
        log.info("根据用户主键获取用户得到的总的收益（包括静态收益和动态收益）请求超时，走熔断！");
        return BigDecimal.ZERO;
    }

    @Override
    public BigDecimal getTotalXWCAmount(@RequestParam("userId") String userId) {
        log.info("根据用户主键获取总的XWC金额请求超时，走熔断！");
        return BigDecimal.ZERO;
    }

    @Override
    public BigDecimal getTotalBTCAmount(@RequestParam("userId") String userId) {
        log.info("根据用户主键获取BTC兑换金额请求超时，走熔断！");
        return BigDecimal.ZERO;
    }

    @Override
    public BigDecimal getTotalExchangeAmount(@RequestParam("userId") String userId, @RequestParam("coinType") String coinType) {
        log.info("根据用户主键获取兑换总金额请求超时，走熔断！");
        return BigDecimal.ZERO;
    }

    @Override
    public BigDecimal getTotalWalletAmount(@RequestParam("userId") String userId, @RequestParam("coinType") String coinType) {
        log.info("根据用户主键和币种类型获取用户钱包金额请求超时，走熔断！");
        return BigDecimal.ZERO;
    }

    @Override
    public BigDecimal getTotalMoneyTransferAmount(@RequestParam("userId") String userId, @RequestParam("coinType") String coinType, @RequestParam("transferType") Integer transferType) {
        log.info("根据用户主键、币种类型、划转类型获取总的资金划转金额请求超时，走熔断！");
        return BigDecimal.ZERO;
    }

    @Override
    public Map<String, Object> getIncomes(@PathVariable("userId") String userId, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "pageSize", required = false) Integer pageSize) throws Exception {
        log.info("通过用户主键分页获取收益信息请求超时，走熔断！");
        return Maps.newHashMap();
    }

    @Override
    public Map<String, Object> getUsdBills(@PathVariable("userId") String userId, @RequestParam("coinType") String coinType, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        log.info("通过用户主键、币种类型分页获取usd账单列表请求超时，走熔断！");
        return Maps.newHashMap();
    }

    @Override
    public AZPlanWallet getAZPlanWallet(@RequestParam("userId") String userId, @RequestParam("coinType") String coinType) {
        log.info("根据用户主键、币种类型获取用户AZ计划钱包的信息请求超时，走熔断！");
        return AZPlanWallet.builder().build();
    }

    @Override
    public List<TransferInOutFlow> getTransferInOutFlowList(@RequestParam("userId") String userId, @RequestParam("coinType") String coinType, @RequestParam(value = "flowType", required = false) Integer flowType) {
        log.info("根据用户主键、币种类型、流水类型获取某一个用户的相关币种转入与转出流水请求超时，走熔断！");
        return Collections.emptyList();
    }

    @Override
    public int withdraw(@RequestBody WithdrawOrder withdrawOrder) {
        log.info("提币请求超时，走熔断！");
        return 0;
    }

    @Override
    public List<WithdrawOrder> getWithdrawOrderList(@RequestParam(value = "userId", required = false) String userId, @RequestParam(value = "coinType", required = false) String coinType) {
        log.info("根据用户主键、币种类型获取提币订单请求超时，走熔断！");
        return Collections.emptyList();
    }

    @Override
    public List<UserRelativeVersionBO> getUserRelativeVersionBOList(@RequestParam("userId") String userId) {
        log.info("根据用户主键获取获取推荐人的相关币种版本号和矿池版本号请求超时，走熔断！");
        return Collections.emptyList();
    }

    @Override
    public List<AZPlanBalance> getUserOrePoolVersionList() {
        log.info("获取所有用户的矿池版本号请求超时，走熔断！");
        return Collections.emptyList();
    }

    @Override
    public List<EntryMoneyFlow> getEntryMoneyFlowList() {
        log.info("获取入金流水列表请求超时，走熔断！");
        return Collections.emptyList();
    }

    @Override
    public WithdrawBO getWithdrawList(@RequestBody WithdrawBO withdrawBO) {
        log.info("获取提币订单列表请求超时，走熔断！");
        return WithdrawBO.builder().build();
    }

    @Override
    public WithdrawOrder getWithdrawOrder(@RequestParam("id") String id) {
        log.info("根据提币订单主键获取单个提币订单请求超时，走熔断！");
        return WithdrawOrder.builder().build();
    }

    @Override
    public int updateWithdrawOrder(@RequestBody WithdrawOrder withdrawOrder) {
        log.info("更新提币订单请求超时，走熔断！");
        return 0;
    }

    @Override
    public void generateStaticIncome() {
        log.info("手动执行定时任务产生静态收益请求超时，走熔断！");
    }

    @Override
    public String manualPrintMemoryTree(@RequestParam(value = "userId", required = false) String userId) {
        log.info("手动打印内存树请求超时，走熔断！");
        return "manualPrintMemoryTree request timeout!";
    }

    @Override
    public BigDecimal getAllChildAccountTotalEntryAmount(@RequestParam(value = "userId", required = false) String userId) {
        log.info("获取对应父账户下面的所有子账户累计入金金额请求超时，走熔断！");
        return BigDecimal.ZERO;
    }

    @Override
    public Map<String, Object> getIndirectRecommends(@RequestParam(value = "parentId") String parentId, @RequestParam(value = "entryMoneyState", required = false) Integer entryMoneyState, @RequestParam(value = "page", required = false) Integer page, @RequestParam(value = "pageSize", required = false) Integer pageSize) {
        log.info("获取所有的间接子节点列表请求超时，走熔断！");
        return Maps.newHashMap();
    }

    @Override
    public RechargeTranBO getDepositList(@RequestBody RechargeTranBO rechargeTranBO) {
        log.info("获取充值列表请求超时，走熔断！");
        return RechargeTranBO.builder().build();
    }

    @Override
    public UserAssetBO getUserAssetList(@RequestBody UserAssetBO userAssetBO) {
        log.info("获取用户资产列表请求超时，走熔断！");
        return UserAssetBO.builder().build();
    }

    @Override
    public void markInnerUser(@RequestParam(value = "userId", required = false) String userId) {
        log.info("标记内部用户请求超时，走熔断！");
    }

    @Override
    public EntryMoneyFlowBO getEntryMoneyFlowList(@RequestBody EntryMoneyFlowBO entryMoneyFlowBO) {
        log.info("获取入金列表请求超时，走熔断！");
        return EntryMoneyFlowBO.builder().build();
    }

    @Override
    public ExchangeFlowBO getExchangeFlowList(@RequestBody ExchangeFlowBO exchangeFlowBO) {
        log.info("获取兑换流水列表请求超时，走熔断！");
        return ExchangeFlowBO.builder().build();
    }

    @Override
    public IncomeStatisticsDailyBO getIncomeStatisticsList(@RequestBody IncomeStatisticsDailyBO incomeStatisticsDailyBO) {
        log.info("获取收益统计日报列表请求超时，走熔断！");
        return IncomeStatisticsDailyBO.builder().build();
    }

    @Override
    public IncomeStatisticsDailyBO getIncomeDetailList(@RequestBody IncomeStatisticsDailyBO incomeStatisticsDailyBO) {
        log.info("获取收益明细列表请求超时，走熔断！");
        return IncomeStatisticsDailyBO.builder().build();
    }

    @Override
    public int inSiteTransfer(@RequestBody InSiteUserBO inSiteUserBO) {
        log.info("站内转账请求超时，走熔断！");
        return 0;
    }

    @Override
    public BigDecimal getFrozenAmount(@RequestParam("userId") String userId, @RequestParam("coinType") String coinType) {
        log.info("根据用户主键和币种类型获取未审核的（冻结的）的提币总金额请求超时，走熔断！");
        return BigDecimal.ZERO;
    }

    @Override
    public int addAzNotice(@RequestBody AzNotice azNotice) {
        log.info("添加公告请求超时，走熔断！");
        return 0;
    }

    @Override
    public int updateAzNotice(@RequestBody AzNotice azNotice) {
        log.info("编辑公告请求超时，走熔断！");
        return 0;
    }

    @Override
    public AzNotice getAzNoticeById(@PathVariable("id") String id) {
        log.info("根据公告主键查询单个公告请求超时，走熔断！");
        return AzNotice.builder().build();
    }

    @Override
    public AzNoticeBO getAzNoticeList(AzNoticeBO azNoticeBO) {
        log.info("根据相关的检索条件获取公告列表请求超时，走熔断！");
        return AzNoticeBO.builder().build();
    }

    @Override
    public int upDownAzNotice(AzNotice azNotice) {
        log.info("修改公告的上线与下线状态请求超时，走熔断！");
        return 0;
    }

    @Override
    public AZPlanBalance add(@RequestBody AZPlanBalance azPlanBalance) {
        return null;
    }

    @Override
    public int deleteById(@PathVariable("id") String id) {
        return 0;
    }

    @Override
    public AZPlanBalance updateByIdSelective(@PathVariable("id") String id, @RequestBody AZPlanBalance record) {
        return null;
    }

    @Override
    public AZPlanBalance updateById(@PathVariable("id") String id, @RequestBody AZPlanBalance record) {
        return null;
    }

    @Override
    public AZPlanBalance getById(@PathVariable("id") String id) {
        return null;
    }

    @Override
    public List<AZPlanBalance> getByIds(@RequestBody Set<String> ids) {
        return null;
    }

    @Override
    public PageVO<AZPlanBalance> getPage(@RequestBody PageQO<? extends Model> pageQO) {
        return null;
    }

    @Override
    public String trace(@PathVariable("command") String cmd) {
        log.info("测试或诊断登录凭证信息发生请求超时，走熔断！");
        return "trace request timeout!";
    }
}
